(function ($) {
    var $body = $('body');
    var DocHeight = $(window).height();
    $body.height(DocHeight - 35);
});
function immediateBid() {
    //_openPopups(
    //    $('body'), "inputBox.html", {
    //            width: 0,
    //            height: 0
    //    });
    var body = $('body');
    var bodyWidth = body.width();
    var iframeWidthCenter = (bodyWidth - 350) / 2;
    var popUp = document.getElementById("popupcontent");
    popUp.style.top = "250px";
    popUp.style.left = iframeWidthCenter + "px";
    popUp.style.width = "350px";
    popUp.style.height = "250px";
    popUp.style.visibility = "visible";
    $("#name").focus();
    $("#main_div").css({
        "opacity": "0.5",
        "pointer-events": "none"
    });

}
function cancel() {
    //$("#mainDiv").remove();
    //$("#bottomDiv").remove();
    $("#main_div").css({
        "opacity": "1",
        "pointer-events": "all  "
    });
    $("#name").val("");
    $("#telephone").val("");
    $("#moneySum").val("");
    var popUp = document.getElementById("popupcontent");
    popUp.style.visibility = "hidden";
    
}
function _openPopups(body, url, iframSize) {

    if ($("#mainDiv").length > 0) {
        $("#mainDiv").remove();
    }
    if ($("#bottomDiv").length > 0) {
        $("#bottomDiv").remove();
    }
    var iframSizeWidth = iframSize.width;
    var iframeSizeHeight = iframSize.height;
    var mainDiv = $("<div></div>");
    var bottomDiv = $("<div style='width: 100%;height: 100%;'></div>");
    var iframe = $("<iframe></iframe>");
    iframe.attr({
        src: url,
        scrolling: "no",
        width: iframSizeWidth,
        height: iframeSizeHeight,
        border: 0,
        frameborder: "no"
    });
    var windowHeight = window.height;
    var windowWidth = window.width;
    var bodyHeight = body.height();
    var bodyWidth = body.width();
    bodyHeight = body.height();
    bodyWidth = body.width();
    var iframeHeight = iframe.height();
    var iframeWidth = iframe.width();
    var iframeHeightCenter = (bodyHeight - iframeSizeHeight) / 2;
    var iframeWidthCenter = (bodyWidth - iframSizeWidth) / 2;
    iframeHeightCenter = parseInt(150);
    iframeWidthCenter = parseInt(iframeWidthCenter);
    bodyHeight = parseInt(bodyHeight);
    bodyWidth = parseInt(bodyWidth);
    bottomDiv.attr({
        id: "bottomDiv"
    });
    bottomDiv.css({
        "opacity": 0.5,
        "float": "left",
        "top": "0px",
        "left": "0px",
        //"width": bodyWidth + "px",
        //"height": bodyHeight + "px",
        "display": "inline-block",
        "position": "absolute",
        "z-index": "99",
        "background-color": "black",

    });
    mainDiv.css({
        "top": iframeHeightCenter + 'px',
        "left": iframeWidthCenter + 'px',
        "width": iframSizeWidth + 'px',
        "height": iframeSizeHeight + 'px',
        "display": "inline-block",
        "position": "absolute",
        "z-index": "100",
        "border-radius": "3px",
        "background-color": "#F9F9F9"
    });
    mainDiv.attr({
        id: "mainDiv"
    });
    body.resize(function () {
        bodyHeight = body.height();
        bodyWidth = body.width();
        bodyHeight = parseInt(bodyHeight);
        bodyWidth = parseInt(bodyWidth);
        bottomDiv.css({
            "width": bodyWidth + "px",
            "height": bodyHeight + "px"
        });
        iframeHeightCenter = (bodyHeight - iframeSizeHeight) / 2;
        iframeWidthCenter = (bodyWidth - iframSizeWidth) / 2;
        mainDiv.css({
            "top": iframeHeightCenter + 'px',
            "left": iframeWidthCenter + 'px'
        });
    });
    mainDiv.append(iframe);
    body.append(bottomDiv);
    body.append(mainDiv);
}
function confirm() {
    var name = $("#name").val();
    var telephone = $("#telephone").val();
    var money = $("#moneySum").val();
    var flag = checkName(name);
    if (flag) {
        var flag_1 = checkTel(telephone);
        if (flag_1) {
            var flag_2 = checkMoney(money);
            if (flag_2) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
}
function checkName(param) {
    if (param == "") {
        alert("姓名不能为空，请输入姓名。");
        $("#name").focus();
        return false;
    } else {
        var reg = /^[\u4E00-\u9FA5]{2,4}$/;
        if (!reg.test(param)) {
            alert("请输入2-4位的中文姓名。");
            $("#name").focus().select();
            return false;
        } else {
            return true;
        }
    }
}
function checkTel(param) {
    if (param == "") {
        alert("电话不能为空,请输入电话。");
        $("#telephone").focus();
        return false;
    } else {
        var reg = /^1(3|4|5|7|8)\d{9}$/;
        if (!reg.test(param)) {
            alert("请输入正确的电话号码。");
            $("#telephone").focus().select();
            return false;
        } else {
            return true;
        }
    }
}
function checkMoney(param) {
    if (param == "") {
        alert("金额不能为空。");
        $("#moneySum").focus();
        return false;
    } else {
        return true;
    }
}

